/*
	jGrouse framework
	Copyright 2007 by Denis Riabtchik 
	All rights reserved.
	
	Licensed under modified BSD license. See license.txt for details
*/


/**
	jGrouse library version 0.1. <br>
	(c) 2006, 2007 by Denis Riabtchik
	All rights reserved
	
	@file jgrouse.js
*/

/**
* Root object of the namespace
* @namespace jgrouse
*/
jgrouse = 
{
	/**
		default name of startup file
		@variable _startupFile
	*/
	_startupFile : 'jgrouse.js',
	/**
		array of functions that should be called on app shutdown
		@variable {function()[]} _closeHooks
	*/
	_closeHooks : []
};



/**
*	Structure containing jGrouse configuration.
	@struct jgrouse_config
*/
if (typeof jgrouse_config == 'undefined')
{
	jgrouse_config = {};
}
/**Inital log level @variable logLevel*/
/**Suppress logging in classes @variable nologs*/ 
/**Enable debugging for dynamically loaded modules @variable debug*/
/**Suppress creation of history tracker IFrame @variable nohistory*/


/**@scope jgrouse*/

/**
* Contains reference to global namespace	
  @variable _global
*/
jgrouse._global = this;

/**
* Special exception that is used to break iterators
* @variable $break
*/
jgrouse.$break = "break exception";


/**
* Base class for jgrouse exceptions
* @class jgrouse.Exception
*/
/**
* @constructor Exception
* @param {String} messageCode - string representing the error
* @param {optional Array} params associated with the error
*/
jgrouse.Exception = function(messageCode, params)
{
	this._messageCode = messageCode;
	this._params = params;
}

jgrouse.Exception.prototype = 
{
	/**
	* @function toString
	* @returns string representation of exception
	*/
	toString : function()
	{
		return this._messageCode;
	}
}

/**@scope jgrouse*/
/**
* Used to indicate that method is not implemented/abstract
* @function notImplemented
* @param {String} methodName name of the method that is not implemented
*/
jgrouse.notImplemented = function(methodName)
{
	throw new jgrouse.Exception('notImplemented ' + methodName);
}

/**
	Adds a shutdown hook - a function that should be called at app shutdown
	@function addUnloadHook
	@param {function()} func - hook that should be called at shutdown
*/
jgrouse.addUnloadHook = function(func)
{
	jgrouse._closeHooks.push(func);
}

/**
    Dummy function that is used as a placeholder
    @function dummy
*/
jgrouse.dummy = function()
{
}